package com.hhkj.api.train.service.biz.impl;

import com.hhkj.admin.train.domain.Train;
import com.hhkj.api.train.common.cont.ApiTrainConst;
import com.hhkj.api.train.model.info.res.HistoryTrainRes;
import com.hhkj.api.train.service.biz.ApiTrainHistoryBizService;
import com.hhkj.api.train.service.extend.ApiStudentTrainHistoryExtendService;
import com.ruoyi.common.exception.GlobalException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 历史培训 Service
 *
 * @author RuoYi
 * @since 2023/6/8
 */
@Service
public class ApiTrainHistoryBizServiceImpl implements ApiTrainHistoryBizService
{
    @Autowired
    private ApiStudentTrainHistoryExtendService apiStudentTrainHistoryExtendService;

    /**
     * 分页查询历史培训记录
     *
     * @param train 参数
     * @return 历史培训记录
     */
    @Override
    public List<HistoryTrainRes> pageHistoryTrain(Train train) {
        List<HistoryTrainRes> historyTrainRes;
        if (ApiTrainConst.TypeCode.TEST.getCode().equals(train.getTypeCode())) {
            historyTrainRes = apiStudentTrainHistoryExtendService.pageHistoryTest();
        } else if (ApiTrainConst.TypeCode.PRACTISE.getCode().equals(train.getTypeCode())) {
            historyTrainRes = apiStudentTrainHistoryExtendService.pageHistoryPractice();
        } else {
            throw new GlobalException("选择查看的类型！");
        }
        return historyTrainRes;
    }
}
